﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Data;
using System.Data.OleDb;
using You2V.Data.Shared;

namespace You2V.LocalDBLayer
{
    public class You2VDataDictionary
    {
        #region AreaList
        public static List<Area> AreaList 
        {
            get
            {
                if (m_AreaList == null || m_AreaList.Count == 0)
                {
                    GetAreaList();
                }

                return m_AreaList;
            }
        }

        private static List<Area> m_AreaList;

        private static bool GetAreaList()
        {
            m_AreaList = new List<Area>();

            string sqlQuery = "SELECT areaid,areaname FROM area ORDER BY areaname";
            DataTable dt = DBAccess.GetDataTable(sqlQuery);

            if (dt == null)
            {
                return false;
            }

            foreach (DataRow row in dt.Rows)
            {
                Area item = new Area();

                item.area = (string)row["areaid"];
                item.areaname = (string)row["areaname"];
                m_AreaList.Add(item);
            }

            return true;
        }
        #endregion

        #region GenderList
        public static List<string> GenderList
        {
            get
            {
                if (m_GenderList == null || m_GenderList.Count == 0)
                {
                    m_GenderList = new List<string>();
                    m_GenderList.Add("男");
                    m_GenderList.Add("女");
                    m_GenderList.Add("未知");
                }

                return m_GenderList;
            }
        }

        private static List<string> m_GenderList;
        #endregion

        #region NationList
        public static List<string> NationList
        {
            get
            {
                if (m_NationList == null || m_NationList.Count == 0)
                {
                    m_NationList = new List<string>();
                    m_NationList.Add("汉族");
                    m_NationList.Add("壮族");
                    m_NationList.Add("侗族");
                    m_NationList.Add("瑶族");
                    //m_NationList.Add("红瑶族");
                    m_NationList.Add("苗族");
                    m_NationList.Add("回族");
                    m_NationList.Add("水族");
                    m_NationList.Add("毛南族");
                    m_NationList.Add("其他民族");
                    m_NationList.Add("未知");
                }

                return m_NationList;
            }
        }
        private static List<string> m_NationList;
        #endregion

		#region ActionList
		private static List<StudentActionEnum> m_StuActionList;
		public static List<StudentActionEnum> StuActionList
		{
			get
			{
				if (m_StuActionList == null || m_StuActionList.Count == 0)
				{
					m_StuActionList = GetStudentActionList("WHERE status = 1");
				}

				return m_StuActionList;
			}
		}
		public static List<StudentActionEnum> GetStudentShowedOnGridActionList()
		{
			string query = "WHERE status = 1 and showedAsPrimary = 1";
			return GetStudentActionList(query);
		}
		public static List<StudentActionEnum> GetStudentAvaliableActionList()
		{
			string query = "WHERE status = 1";
			return GetStudentActionList(query);
		}
		public static List<StudentActionEnum> GetStudentActionList(string query)
		{
			m_StuActionList = new List<StudentActionEnum>();

			string sqlQuery = string.Format("SELECT ID, action_name, showedAsPrimary, allowAccount, status, created_by, created_date, modified_by, modified_date FROM setting_action {0} ORDER BY ID", query);
			DataTable dt = DBAccess.GetDataTable(sqlQuery);

			foreach (DataRow row in dt.Rows)
			{
				m_StuActionList.Add(GetStudentAction(row));
			}

			return m_StuActionList;
		}
		public static StudentActionEnum GetStudentAction(DataRow row)
		{
			StudentActionEnum item = new StudentActionEnum();
			item.actionid = (int)row["ID"];
			item.action = (string)row["action_name"];

			if ((int)row["showedAsPrimary"] == 1)
			{
				item.ShowedAsPrimary = true;
			}
			else
				item.ShowedAsPrimary = false;

			if ((int)row["allowAccount"] == 1)
			{
				item.ShowAccount = true;
			}
			else
				item.ShowAccount = false;

			if ((int)row["status"] == 1)
			{
				item.Status = true;
			}
			else
				item.Status = false;
			return item;
		}
		#endregion

        #region 资助状态
        public static List<string> SponsorShipTrackingList
        {
            get
            {
                if (m_SponsorShipTrackingList == null || m_SponsorShipTrackingList.Count == 0)
                {
                    m_SponsorShipTrackingList = new List<string>();
                    m_SponsorShipTrackingList.Add("未开始资助");
                    m_SponsorShipTrackingList.Add("无跟踪信息");
                    m_SponsorShipTrackingList.Add("正常资助");
                    m_SponsorShipTrackingList.Add("需要回访");
                    m_SponsorShipTrackingList.Add("资助完成");
                    m_SponsorShipTrackingList.Add("资助中断");
                }

                return m_SponsorShipTrackingList;
            }
        }

        private static List<string> m_SponsorShipTrackingList;
        #endregion

        #region login Message
        public static string currentUser = "likong";
		#endregion
	}
}
